from django.db import models

# Create your models here.

class Client(models.Model):
    """
    客户端
    """
    name = models.CharField(max_length=50, verbose_name='客户端名称')

    def __str__(self):
        return str(self.name)

    class Meta:
        ordering = ('-pk',)
        verbose_name = '客户端'
        verbose_name_plural = verbose_name

class ClientRanking(models.Model):
    """
    客户端数据
    """
    client = models.ForeignKey(Client, verbose_name='客户端', on_delete=models.CASCADE)
    fraction = models.IntegerField(verbose_name='分数', default=1)
    highest = models.BooleanField(verbose_name='当前客户端最高分', default=False, help_text='是否为当前客户端最高分数，是的话为True')
    created = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')

    def __str__(self):
        return str(self.fraction)

    class Meta:
        ordering = ('-fraction', 'created', )
        verbose_name = '客户端数据'
        verbose_name_plural = verbose_name